package com.wapper;

import java.util.Scanner;

public class Homework {
    public static void main(String[] args) {


        Scanner sca = new Scanner(System.in);
        System.out.println("请输入名字；");
        String   name=sca.next();
        System.out.println("请输入密码；");
        String  pwd=sca.next();
        System.out.println("请输入邮箱；");
        String  email=sca.next();

        try {
            System.out.println("信息输入成功");
            user(name,pwd,email);
        } catch (Exception e) {
            System.out.println(e.getMessage());;
        }
    }

public static void user(String name ,String pwd ,String email) throws Exception {


        if(!(name.length()>=2&&name.length()<=4))
            throw new Exception("账号不符合规范");
        if(!(pwd.length()==6&&isAllDigits(pwd))) {
            throw new Exception("密码不符合规范");
        }
       int index =email.indexOf("@");
        if(!(index!=-1&&email.indexOf(".")==index+1&&email.indexOf("@", index+1) ==-1)) {
    throw new Exception("邮箱不符合规范");
        }
}
    public static boolean isAllDigits(String str) {
        if (str == null || str.isEmpty()) {
            return false;
        }
        for (int i = 0; i < str.length(); i++) {
            if (!Character.isDigit(str.charAt(i))) {
                return false;
            }
        }
        return true;
    }


}

